package com.itmatter.classifier.basicdb;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import com.enigmastation.classifier.impl.FisherClassifierImpl;
import com.enigmastation.extractors.impl.StemmingWordLister;
import org.apache.log4j.Logger;

/**
 *
 * @author Daniel Fisla, dfisla@itmatter.com, ITMATTER Inc., http://www.itmatter.com, Copyright 2010, LGPLv3
 */
public class HibernateClassifierImpl extends FisherClassifierImpl {

    private static final Logger logger = Logger.getLogger(HibernateClassifierImpl.class.getName());
    private boolean initialized = false;
    
    /**
     * 
     */
    public HibernateClassifierImpl() {
        //init();
    }

    /**
     * 
     */
    @Override
    public synchronized void init() {

        if (!initialized) {
            logger.debug("INIT!");
            
            if (getClassifierDataModelFactory() == null) {
                HibernateClassifierDataModelFactory factory = new HibernateClassifierDataModelFactory();
                factory.init();
                setClassifierDataModelFactory(factory);
            }
         
            if (wordLister == null) {
                wordLister = new StemmingWordLister();
            }

            initialized = true;
        }
    }
    
    /**
     * 
     */
    public void deleteAllData(){
        HibernateClassifierDataModelFactory factory = (HibernateClassifierDataModelFactory) this.getClassifierDataModelFactory();
        factory.deleteAllData();
        
    }
}
